package myApp.KnorrAndroid.view.member;

import java.util.Vector;

import myApp.Constant.ActionEventConstant;
import myApp.Constant.IntentConstants;
import myApp.KnorrAndroid.R;
import myApp.KnorrAndroid.common.ActionEvent;
import myApp.KnorrAndroid.common.ModelEvent;
import myApp.KnorrAndroid.controller.UserController;
import myApp.KnorrAndroid.view.KnorrBaseActivity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class RegisterView extends KnorrBaseActivity implements OnClickListener{
	
	
	EditText etUserName;
	EditText etPassWord; //mat khau
	EditText etPassWord2; //mat khau nhap lai
	EditText etEmail;
	Button btRegister;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.layout_register_view);  
		etUserName = (EditText)findViewById(R.id.etUserName);
		etPassWord = (EditText)findViewById(R.id.etPassWord);
		etPassWord2 = (EditText)findViewById(R.id.etPassWord2);
		etEmail = (EditText)findViewById(R.id.etEmail);
		btRegister = (Button)findViewById(R.id.btRegister);
		btRegister.setOnClickListener(this);
	}
	
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.btRegister:
			requestRegister("banghn", "hnbang1988@gmail.com", "123456");
			break;

		default:
			break;
		}
		
	}
	
	//BangHN: request dang ky tai khoan
	private void requestRegister(String userName, String pass, String fullName){
		Vector<String> data = new Vector<String>();
		data.addElement(IntentConstants.INTENT_USER_NAME);
		data.addElement(userName);
		data.addElement(IntentConstants.INTENT_PASSWORD);
		data.addElement(pass);
		data.addElement(IntentConstants.INTENT_FULL_NAME);
		data.addElement(fullName);
		
		ActionEvent e = new ActionEvent();
		e.action = ActionEventConstant.REGISTER;
		e.viewData = data;
		e.sender = RegisterView.this;
		UserController.getInstance().handleViewEvent(e);
	}
	
	@Override
	public void handleModelViewEvent(ModelEvent modelEvent) {
		switch (modelEvent.getActionEvent().action) {
		case ActionEventConstant.REGISTER:
			
			break;
		default:
			super.handleModelViewEvent(modelEvent);
			break;
		}
	}
	
	@Override
	public void handleErrorModelViewEvent(ModelEvent modelEvent) {
		// TODO Auto-generated method stub
		super.handleErrorModelViewEvent(modelEvent);
	}
	
}
